package com.ruoyi.production.service.impl.graftingclip;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.production.domain.graftingclip.GraftingclipApply;
import com.ruoyi.production.mapper.graftingclip.GraftingclipApplyMapper;
import com.ruoyi.production.service.graftingclip.IGraftingclipApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.OrderAllocationMapper;
import com.ruoyi.order.domain.OrderAllocation;

/**
 * 嫁接夹申请Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@Service
public class GraftingclipApplyServiceImpl implements IGraftingclipApplyService
{
    @Autowired
    private GraftingclipApplyMapper graftingclipApplyMapper;
    @Autowired
    private OrderAllocationMapper orderAllocationMapper;

    /**
     * 查询嫁接夹申请
     *
     * @param graftingclipApplyId 嫁接夹申请ID
     * @return 嫁接夹申请
     */
    @Override
    public GraftingclipApply selectGraftingclipApplyById(Long graftingclipApplyId)
    {
        return graftingclipApplyMapper.selectGraftingclipApplyById(graftingclipApplyId);
    }

    /**
     * 查询嫁接夹申请列表
     *
     * @param graftingclipApply 嫁接夹申请
     * @return 嫁接夹申请
     */
    @Override
    public List<GraftingclipApply> selectGraftingclipApplyList(GraftingclipApply graftingclipApply)
    {
        return graftingclipApplyMapper.selectGraftingclipApplyList(graftingclipApply);
    }

    /**
     * 新增嫁接夹申请
     *
     * @param graftingclipApply 嫁接夹申请
     * @return 结果
     */
    @Override
    public int insertGraftingclipApply(GraftingclipApply graftingclipApply)
    {
        Long orderAllocationId = graftingclipApply.getOrderAllocationId();
        OrderAllocation orderAllocation = orderAllocationMapper.selectOrderAllocationById(orderAllocationId);
        graftingclipApply.setOrderId(orderAllocation.getOrderId());














        graftingclipApply.setCreateTime(DateUtils.getNowDate());



        return graftingclipApplyMapper.insertGraftingclipApply(graftingclipApply);
    }

    /**
     * 修改嫁接夹申请
     *
     * @param graftingclipApply 嫁接夹申请
     * @return 结果
     */
    @Override
    public int updateGraftingclipApply(GraftingclipApply graftingclipApply)
    {
        graftingclipApply.setUpdateTime(DateUtils.getNowDate());
        return graftingclipApplyMapper.updateGraftingclipApply(graftingclipApply);
    }

    /**
     * 批量删除嫁接夹申请
     *
     * @param graftingclipApplyIds 需要删除的嫁接夹申请ID
     * @return 结果
     */
    @Override
    public int deleteGraftingclipApplyByIds(Long[] graftingclipApplyIds)
    {
        return graftingclipApplyMapper.deleteGraftingclipApplyByIds(graftingclipApplyIds);
    }

    /**
     * 删除嫁接夹申请信息
     *
     * @param graftingclipApplyId 嫁接夹申请ID
     * @return 结果
     */
    @Override
    public int deleteGraftingclipApplyById(Long graftingclipApplyId)
    {
        return graftingclipApplyMapper.deleteGraftingclipApplyById(graftingclipApplyId);
    }
}
